﻿using UnityEditor.Build;
using UnityEditor;

public class SwitchPlatform : IActiveBuildTargetChanged
{
    public int callbackOrder => 0;

    public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget)
    {
    
        //throw new System.NotImplementedException();

        if (newTarget == BuildTarget.Android)
        {
            InitAndroidPlayerSetting();
        }
        else if(newTarget == BuildTarget.iOS)
        {
            InitIOSPlayerSetting();
        }
        else if (newTarget == BuildTarget.StandaloneWindows)
        {
            InitWindowsPlayerSetting();
        }
    }


    public void InitIOSPlayerSetting()
    {
        PlayerSettings.allowedAutorotateToPortrait = true;
    }

    public void InitAndroidPlayerSetting()
    {
        PlayerSettings.allowedAutorotateToPortrait = false;
    }

    public void InitWindowsPlayerSetting()
    {

    }

}
